import java.util.List;
import java.util.Random;
import java.util.Scanner;
import java.util.Stack;

public class Test {
    public static void main(String[] args) {

    }
    public static void main13(String[] args) {
        BinaryTree.TreeNode A = new BinaryTree.TreeNode('A');
        BinaryTree.TreeNode B = new BinaryTree.TreeNode('B');
        BinaryTree.TreeNode C = new BinaryTree.TreeNode('C');
        BinaryTree.TreeNode D = new BinaryTree.TreeNode('D');
        BinaryTree.TreeNode E = new BinaryTree.TreeNode('E');
        BinaryTree.TreeNode F = new BinaryTree.TreeNode('F');
        BinaryTree.TreeNode G = new BinaryTree.TreeNode('G');
        BinaryTree.TreeNode P = new BinaryTree.TreeNode('P');
        A.left = B;
        A.right = C;
        B.left = D;
        B.right = E;
        C.left = F;
        C.right = G;
        D.right = P;
        Stack<BinaryTree.TreeNode> stack =new Stack<>();
        BinaryTree binaryTree=new BinaryTree();
        //BinaryTree.TreeNode root=binaryTree.Creat();
        binaryTree.getPath(A,F,stack);
        System.out.println("");
    }
    public static void main12(String[] args) {
        BinaryTree binaryTree=new BinaryTree();
        BinaryTree.TreeNode root=binaryTree.Creat();
        List<List<BinaryTree.TreeNode>>ret=BinaryTree.levelOrder_k11(root);
        System.out.println(" ");
    }
    public static void main11(String[] args) {
        BinaryTree binaryTree=new BinaryTree();
        BinaryTree.TreeNode root =binaryTree.Creat();
        binaryTree.preOredr(root);
        System.out.println("");
        binaryTree.preOredrNor(root);
        System.out.println("");
        binaryTree.inOredrNor(root);
        System.out.println("");
        binaryTree.inOredr(root);
        binaryTree.postOredrNor(root);
    }
    public static void main10(String[] args) {
        BinaryTree binaryTree=new BinaryTree();
        BinaryTree.TreeNode root =binaryTree.Creat();
        String s= binaryTree.tree2str(root);
        System.out.println(s);
    }
    public static void main9(String[] args) {
        char[]A= "ABC".toCharArray();
        char[]B={'B','A','C'};
        BinaryTree binaryTree =new BinaryTree();
        BinaryTree.TreeNode root=binaryTree.buildTree(A,B);
        System.out.println("");
    }
    public static void main8(String[] args) {
        BinaryTree binaryTree=new BinaryTree();
        BinaryTree.TreeNode root=binaryTree.Creat();
        System.out.println(binaryTree.isCompleteTree1(root));
    }
    public static void main7(String[] args) {
        BinaryTree binaryTree=new BinaryTree();
        BinaryTree.TreeNode root=binaryTree.Creat();
        List<List<BinaryTree.TreeNode>>ret=BinaryTree.levelOrder_k1(root);
        for (int i = 0; i < ret.size(); i++) {
            for (int j = 0; j < ret.get(i).size(); j++) {
                System.out.print(ret.get(i).get(j).val+" ");
            }
            System.out.println("");
        }
    }
    public static void main6(String[] args) {
        BinaryTree binaryTree=new BinaryTree();
        BinaryTree.TreeNode root=binaryTree.Creat();
        BinaryTree.levelOrder(root);
        System.out.println(BinaryTree.isCompleteTree(root));
    }
    public static void main5(String[] args) {
        BinaryTree binaryTree=new BinaryTree();
        String s="AB###";
        BinaryTree.TreeNode root=BinaryTree.CreatTree(s);
        BinaryTree.inOrder(root);
    }

    public static void main4(String[] args) {
        System.out.println();
        BinaryTree binaryTree=new BinaryTree();
        BinaryTree.TreeNode root=binaryTree.Creat3();
        BinaryTree.TreeNode subRoot=binaryTree.Creat4();
        System.out.println(binaryTree.isSubtree(root, subRoot));

    }
    public static void main3(String[] args) {
        BinaryTree binaryTree=new BinaryTree();
       // BinaryTree.TreeNode root=binaryTree.Creat();
   /*     binaryTree.preOredr(binaryTree.root);
        System.out.println("");
        binaryTree.inOredr(binaryTree.root);
        System.out.println("");
        binaryTree.postOredr(binaryTree.root);*/
      /*  binaryTree.preOredr(root);
        List<BinaryTree.TreeNode> ret1=binaryTree.preOredr2(root);
        List<BinaryTree.TreeNode> ret2=binaryTree.inOredr2(root);
        System.out.println("");
        for (BinaryTree.TreeNode x:
             ret1) {
            System.out.print(x.val+" ");
        }
        System.out.println("");
        for (BinaryTree.TreeNode x:
                ret2) {
            System.out.print(x.val+" ");
        }
        binaryTree.size(root);
        System.out.println(binaryTree.size);*/
/*        int ret= binaryTree.getKLevelNodeCount(root,3);
        System.out.println("该层的个数为"+ret);
        int height=binaryTree.getHeight(root);
        System.out.println("该树的高度为"+height);
        System.out.println("");
        System.out.println(binaryTree.find(root, 'E'));*/
        BinaryTree.TreeNode p=binaryTree.Creat1();
        BinaryTree.TreeNode q=binaryTree.Creat2();
        System.out.println(binaryTree.isSameTree(p, q));

    }
    public static void main1(String[] args) {
        int arr1[]={1,2,3,4,5};
        int arr2[]={3,4,5,2,1};
        Solution solution=new Solution();

       // System.out.println(solution.IsPopOrder(arr1, arr2));
        //System.out.println(solution.isUgly(10));
        System.out.println(solution.addDigits(38));
    }

    public static void main2(String[] args) {
        Scanner scanner=new Scanner(System.in);
        int guess=0;
        Random random=new Random();
        int key= random.nextInt(100);
        do{
            System.out.println("请输入你要猜的数字");
             guess=scanner.nextInt();
            if(key<guess){
                System.out.println("猜大了哦");
            } else if (key>guess) {
                System.out.println("猜小了哦");
            }else{
                System.out.println("恭喜你猜对了");
                break;
            }
        }while(true);

    }
}
